﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'ExistsModuleParameterByNameAndModule')
	BEGIN
		DROP  Procedure  ExistsModuleParameterByNameAndModule
	END

GO

CREATE Procedure ExistsModuleParameterByNameAndModule

	(
		@paramName varchar(255),
		@moduleId uniqueidentifier
	)
AS
if exists(
	select Mod_Par_Id from Module_Parameter
	where mod_id=@moduleId and
	Mod_Par_Name=@paramName)
	select 1;
	else
	select 0;
	
	GO
	
	
	IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'sp_MODULE_PARAMETER_FindByNameAndModule')
	BEGIN
		DROP  Procedure  sp_MODULE_PARAMETER_FindByNameAndModule
	END

GO

CREATE Procedure sp_MODULE_PARAMETER_FindByNameAndModule

	(
		@paramName varchar(255),
		@moduleId uniqueidentifier
	)
AS

	select MOD_PAR_ID,VAL_TYP_ID,MOD_ID,MOD_MOD_ID,MOD_PAR_NAME,
	MOD_PAR_DESCRIPTION,MOD_PAR_MANDATORY
	
	 from Module_Parameter
	where mod_id=@moduleId and
	Mod_Par_Name=@paramName
